<include file="public@storage"/>
<style>
    #form {
        margin-top: 100px;
        padding-left: 50px;
        padding-right: 50px;
    }
    .error {
        border-color: red;
    }

    span {
        color: red;
        margin-left: 50px;
        line-height: 30px;
    }

</style>
</head>
<body>

<input type="hidden" id="storageUuid" value="{$storageInfo[0]['uuid']}">
<div>
    <form class="form-horizontal table" id="form" onsubmit = "return checkShelf()" action="{:url('storage/Shelf/addShelf')}" method="post">
        <div class="panel panel-primary">
            <div class="panel-heading">
                <h3 class="panel-title">货架信息</h3>
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <div class="col-md-2 control-label">
                        <label for="floor">所属仓库：</label>
                    </div>
                    <div class="col-md-2">
                        <input type="text" name="name" id="name" class="form-control" value="{$storageInfo[0]['name']}" readonly="false">
                        <input type="hidden" name="storage_uuid" id="storage_uuid" class="form-control" value="{$storageInfo[0]['uuid']}">
                    </div>

                    <div class="col-md-2 control-label">
                        <label for="shelvesCode">货架序号：</label>
                    </div>
                    <div class="col-md-2">
                        <input type="text" name="shelvesCode" id="shelvesCode" class="form-control"  placeholder="必须填">
                        <span id="shelvesCodeError"></span>
                    </div>

                    <div class="col-md-2 control-label">
                        <label for="shelveType">类型：</label>
                    </div>
                    <div class="col-md-2">
                        <select class="form-control" id="shelveType" name="type">
                            <option value="">选择货架类型</option>
                            <volist name="shelfType" id="vo">
                                <option value="{$vo.shelves_type_code}">{$vo.shelves_type_name}</option>
                            </volist>
                        </select>
                        <span id="typeError"></span>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-md-2 control-label">
                        <label for="isDouble">是否双面：</label>
                    </div>
                    <div class="col-md-2">
                        <select class="form-control" id="isDouble" name="isDouble">
                            <option value="1" selected>双面</option>
                            <option value="0">单面</option>
                        </select>
                        <span id="isDoubleError"></span>
                    </div>
                    <div class="col-md-2 control-label">
                        <label for="floor">层数：</label>
                    </div>
                    <div class="col-md-2">
                        <input type="text" name="floor" id="floor" class="form-control" placeholder="必须填">
                        <span id="floorError"></span>
                    </div>
                    <div class="col-md-2 control-label">
                        <label for="floorCount">每层站位数：</label>
                    </div>
                    <div class="col-md-2">
                        <input type="text" name="floorCount" id="floorCount" class="form-control" placeholder="必须填">
                        <span id="floorCountError"></span>
                    </div>
                </div>

            </div>
            <div class="form-group text-center">
                <button type="submit" class="mui-btn mui-btn--raised mui-btn--primary" id="submit" >添加</button>
                <button type='button' class="mui-btn mui-btn--raised mui-btn--primary" onclick="history.back(-1)">取消</button>
            </div>
        </div>
    </form>
</div>
</body>
<script type="text/javascript" src="__STATIC__/storage/js/storage/check.js"></script>
<script type="text/javascript">

    $("#shelveType").change(function () {
        var param = {
            storageUuid: $('#storageUuid').val(),
            type: $('#shelveType').val()
        };
        var success = function (ret) {
            $('#shelvesCode').val(parseInt(ret));
        };
        ajax('get', '/storage/Shelf/getMaxCode', param, success);
    });

    $("#shelvesCode").change(function () {
        var param = {
            storageUuid: $('#storageUuid').val(),
            type: $('#shelveType').val(),
            code:$('#shelvesCode').val()
        };
        if(param.type !== ''){
            var success = function (ret) {
                if(ret.success === false){
                    console.log(ret.message);
                    $('#shelfCodeError').html(ret.message);
                }else{
                    $('#shelfCodeError').html("");
                }
            };
            ajax('get', '/storage/Shelf/judeShelfCode', param, success);
        }
    });

</script>
</html>>